<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.SQLException" %>
<%@ page import="java.util.logging.Level,java.util.logging.Logger" %>
<%@ page import="java.sql.Statement"%>
<%@page import="java.sql.Connection,java.sql.DriverManager" %>


<%
	Connection con=null;
	Statement stmt=null;
	ResultSet rs=null;
	String driver="com.mysql.cj.jdbc.Driver";
	String url="jdbc:mysql://localhost:3306/android?serverTimezone=GMT&characterEncoding=utf-8";
	String user="root";
	String passwd="HandQuite229";
    try{
       Class.forName(driver);
       con=DriverManager.getConnection(url, user, passwd);
       if (con == null)
      		System.out.println("con is null");
       }catch(ClassNotFoundException e){
           out.println(e);
       }catch(SQLException e){
    	   out.println(e);
       }
	try{
		stmt=con.createStatement();
		String sql = "select * from movie_movie_1";
		rs=stmt.executeQuery(sql);
		
		int i = 1;
		out.println("[");
		
		while(rs.next()){
			out.println("{");
			//out.println("\"id\":\"" + i++ + "\"");
			out.println("\"movie_name\":\"" + rs.getString(1) + "\"");
			out.println(",\"movie_src\":\"" + rs.getString(2) + "\"");
			out.println(",\"movie_score\":\"" + rs.getString(3) + "\"");
			out.println(",\"movie_actor\":\"" + rs.getString(4) + "\"");
			out.println(",\"movie_info\":\"" + rs.getString(5) + "\"");
			out.println("}");
			if (!rs.isLast()){
				out.println(",");
			}
        }
		
		/*while(rs.next()){
			out.println("{");
			out.println("\"id\":\"" + rs.getInt(1) + "\"");
			out.println(",\"trainNum\":\"" + rs.getString(2) + "\"");
			out.println(",\"startStation\":\"" + rs.getString(3) + "\"");
			out.println(",\"endStation\":\"" + rs.getString(4) + "\"");
			out.println(",\"StartTime\":\"" + rs.getString(5) + "\"");
			out.println(",\"EndTime\":\"" + rs.getString(6) + "\"");
			out.println("}");
			if (!rs.isLast()){
				out.println(",");
			}
        }*/
		
		out.println("]");
	}catch (SQLException ex) {
		out.println(ex);
	}
%>

